package com.fly.util;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CoversionStringToDate implements Converter<String, Date> {
    @Override
    public Date convert(String s) {
        String first =String.valueOf(s.charAt(4));
        String second = String.valueOf(s.charAt(7));

        SimpleDateFormat format = new SimpleDateFormat("yyyy"+first+"MM"+second+"dd");
        Date date = null;
        try {
            date = format.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
